#！ /usr/bin/python3
# coding=UTF-8

import sqlite3

#创建数据库

# con = sqlite3.connect('./sales.db')

# con.execute('create table book(id primary key,price,name)')

# 打开数据库
books = [('021',25,'大学计算机'),('022',30,'大学英语'),('023',18,'艺术欣赏'),
('024',35, '高级语言程序设计')]
con = sqlite3.connect('./sales.db')
cur = con.cursor()

cur.executemany('replace into book(id,price,name) values (?,?,?)',books)

#cur.execute('update book set price=? where name=?',(25.5,'大学英语'))
cur.execute('select * from book')

for row in cur:
    print(row)

con.commit()
cur.close()
con.close()
